import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/5 15:13
 * @description Map. 记录要替换的位置
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int[] arrayChange(int[] nums, int[][] operations) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            map.put(nums[i], i);
        }
        for (int[] op: operations) {
            int idx = map.get(op[0]);
            map.remove(op[0]);
            map.put(op[1], idx);
        }
        int n = nums.length;
        int[] ans = new int[n];
        for (Map.Entry<Integer, Integer> entry: map.entrySet()) {
            ans[entry.getValue()] = entry.getKey();
        }
        return ans;
    }
}
